package uz.rt.linac;

import uz.rt.units.Angle;

public class Wedge extends LinacComponent
{
// ------------------------------ FIELDS ------------------------------

    private Angle angle = null;
    private boolean fixed;

// --------------------------- CONSTRUCTORS ---------------------------

    public Wedge(Angle angle)
    {
    }

// --------------------- GETTER / SETTER METHODS ---------------------

    public int compareTo(Wedge o)
    {
        return (angle.compareTo(o.getAngle()));
    }

    public Angle getAngle()
    {
        return angle;
    }

    public void setAngle(Angle angle)
    {
        this.angle = angle;
    }

    public boolean isFixed()
    {
        return fixed;
    }

    public void setFixed(boolean fixed)
    {
        this.fixed = fixed;
    }

// ------------------------ CANONICAL METHODS ------------------------

    @Override
    public boolean equals(Object o)
    {
        if (this == o) return true;
        if (!(o instanceof Wedge)) return false;

        Wedge wedge = (Wedge) o;

        return fixed == wedge.fixed && !(angle != null ? !angle
                .equals(wedge.angle) : wedge.angle != null) && distanceToSource
                .compareTo(wedge.getDistanceToSource()) == 0;

    }

    @Override
    public int hashCode()
    {
        int result = angle != null ? angle.hashCode() : 0;
        result = 31 * result + (fixed ? 1 : 0);
        return result;
    }

}
